#include <REGX52.H>
#include "Timer0.H"
#include "Int0.H"



unsigned char IR_State;			//状态位
unsigned int IR_Time; 			//计时变量
unsigned char IR_Date[4]; 		//数据区数组
unsigned char IR_DateFlag;		//数据接收完成信号
unsigned char IR_pDate;			//当前数据位，共32位
unsigned char IR_RepeatFlat;	//重发标志位
unsigned char IR_Address;		//数据存放位置，地址吗
unsigned char IR_Command;		//命令码










void IR_Init(void) //IR初始化
{
	Timer0_Init();
	Int0_Init();



	
}	


void Int0_Routine(void) interrupt 0
{
	if(IR_State==0)
	{	
		Timer0_SetCount(0);
		Timer0_Run(1);
		IR_State=1;
		
	}
	else if(IR_State==1)
	{	
		IR_Time=Timer0_GetCount();
		if(IR_Time>13500-500 && IR_Time<13500+500 )
		{
			IR_State=2;
			
			
		}
		else if(IR_Time>11250-500 && IR_Time<11250+500 )
		{
			IR_RepeatFlat=1;
			Timer0_Run(0);
			
			IR_State=0;
		}
		else
		{
		IR_State=1;
		
		
		}
		
	}
	else if(IR_State==2)
	{
		IR_Time=Timer0_GetCount();
		Timer0_SetCount(0);
		
		if(IR_Time>1120-500 && IR_Time<1120+500 )
		{
			IR_Date()&=~(0X01<<pDate)
			
		}
		
		
	}
	
	
	
}
